/**
 * 
 */
package com.anduinslegacy.bath;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author daddy
 *
 */
public class ReminderServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/* (non-Javadoc)
	 * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String pw = request.getParameter("password");
		if (pw.equals("bathtime")) {
			AuditFactory.create(pw, "success", request.getRemoteAddr());
			ReminderFactory.swap();			
			response.sendRedirect("/bath/bath.jsp");
		} else {
			if (!pw.isEmpty()) {
				AuditFactory.create(pw, "fail", request.getRemoteAddr());
			}
			response.sendRedirect("/bath/swap.jsp?cmd=error");			
		}
	}
}
